#include <bits/stdc++.h>
using namespace std;
int T,n,ans,dep;
int s[200005];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--){
        ans=0;memset(s,0,sizeof(s));
        cin>>n;
        for(int i=1;i<=n;i++){
            int x;bool b=0;
            cin>>x;
            for(int i=1;i<=dep;i++){
                if(x==s[i]) ans+=x,b=1;
            }
            if(!b) s[++dep]=x;
        }
        cout<<ans<<endl;
    }
    return 0;
}